import glob
import random

name_list=[]
for name in glob.glob('./dataset/chip/*.jpg'):
    name_list.append(name)

for name in glob.glob('./dataset/laptop/*.jpg'):
    name_list.append(name)

random.shuffle(name_list)
train_num = int(len(name_list)*0.7)
test_num = int(len(name_list)-train_num)

train_list,test_list=[],[]
train_list=name_list[:train_num]
test_list = name_list[train_num:]

print(len(train_list),len(test_list))

with open('train.txt','w',newline='') as f1:
    for name in train_list:
        f1.write(name+'\n')

f1.close()

with open('test.txt', 'w', newline='') as f2:
    for name in test_list:
        f2.write(name + '\n')

f2.close()